{include file="common/mini-header" title="权限节点"}
<div class="layui-body">
	<!-- 内容主体区域 -->

	<form class="layui-form" action="" style="max-width: 800px;width: 90%;">
		<div class="layui-form-item">
			<label class="layui-form-label">父级菜单</label>
			<div class="layui-input-inline" style="width: 200px;">
				<select name="pid" lay-verify="required">
					<option value="0">一级菜单</option>
					{volist name="menuList" id="item"}
					<option value ="{$item.id}">{$item.name}</option>
					{/volist}
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">菜单名称</label>
			<div class="layui-input-block">
				<input type="text" name="name" required lay-verify="required" placeholder="请输入菜单名称" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">菜单连接</label>
			<div class="layui-input-block">
				<input type="text" name="rules" required lay-verify="required" placeholder="请输入url或者节点(/admin/控制器/方法)" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">所属类型</label>
			<div class="layui-input-block">
				<input type="radio" name="type" value="menu" title="菜单" checked>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="addMenu">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>

</div>
<script>
	layui.use('form', function() {
		var form = layui.form;
		var $ = layui.jquery;
		var layer = layui.layer;

		//监听提交
		form.on('submit(addMenu)', function(data) {
			$.post('./add', data.field, function(rs) {
				if (rs.code == 1) {
					layer.msg(rs.msg)
					setTimeout(function() {
						parent.location.reload();
					}, 1000)
				} else {
					layer.alert(rs.msg)
				}
			})
			return false;
		});
	});
</script>
{include file="common/footer"}
